<template>
	<view class="mine" style="padding: 50rpx;">
		<view style="height: 190rpx;text-align: center;" v-if="isLogin">
			
			<view>
				<u-avatar :src="user.img" :show-sex="true" :sex-icon="user.sex" ></u-avatar>
			</view>
			<text style="font-size: 38rpx;color: #0285ff;text-align: center;">{{user.username}}</text>
			
		</view>
		<view v-if="!isLogin">
			<u-grid :col="3" :border="false" >
				<u-grid-item style="height: 200rpx;">
					<image src="../../static/VCG211248320154-MDG.jpg" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
					<text style="text-align: center;">登录享受更多权益</text>
				</u-grid-item>
				<u-grid-item>
				</u-grid-item>
				<u-grid-item>
					
					<button @click="login" style="background-color: #0285ff;color: #FFFFFF;width: 150rpx;height: 70rpx;border-radius: 50rpx;font-size: 30rpx;line-height: 70rpx;">登录</button>
					<button @click="signin" style="border: 1rpx solid #0285ff;color: #0285ff;width: 150rpx;height: 70rpx;border-radius: 50rpx;font-size: 30rpx;line-height: 70rpx;margin-top: 10rpx">注册</button>
				</u-grid-item>
				
				
			</u-grid>
		</view>
	
		<view style="border-radius: 50rpx;background-color: #FFFFFF;box-shadow: 0 5rpx 5rpx 5rpx #DCDFE6;">
			<u-grid :col="4" :border="false" >
				<u-grid-item @click="toorder(user.order)">
					<!-- <u-icon name="account" :size="46" color="#0285ff"></u-icon> -->
					<view class="" style="width: 70rpx;height: 70rpx;">
						<image src="../../static/我的订单.svg" mode="" style="width: 100%;height: 100%;"></image>
					</view>
					<view class="grid-text">我的订单</view>
				</u-grid-item>
				<u-grid-item>
					<!-- <u-icon name="order" :size="46" color="#0285ff" ></u-icon> -->
					<view class="" style="width: 65rpx;height: 70rpx;">
						<image src="../../static/客户小纪.svg" mode="" style="width: 100%;height: 100%;"></image>
					</view>
					<view class="grid-text">我的分享</view>
				</u-grid-item>
				<u-grid-item>
					<!-- <u-icon name="heart" :size="46" color="#0285ff"></u-icon> -->
					<view class="" style="width: 70rpx;height: 70rpx;">
						<image src="../../static/我的客户.svg" mode="" style="width: 100%;height: 100%;"></image>
					</view>
					<view class="grid-text">我的喜欢</view>
				</u-grid-item>
				<u-grid-item>
					<!-- <u-icon name="plus-people-fill" :size="46" color="#0285ff"></u-icon> -->
					<view class="" style="width: 70rpx;height: 70rpx;">
						<image src="../../static/增值服务.svg" mode="" style="width: 100%;height: 100%;"></image>
					</view>
					<view class="grid-text">我的收藏</view>
				</u-grid-item>
				
			</u-grid>
			
		</view>
		
		<view>
			<view class="u-flex" style="height: 120rpx;border-bottom: 1rpx solid #C0C0C0;">
				<view class="u-flex-1">
					<u-icon name="kefu-ermai" :size="46" color="#0285ff"></u-icon>
				</view>
				<view class="grid-text u-flex-9 u-font-32">客服</view>
			</view>
			<view class="u-flex u-row-left" @click="loginOut" style="height: 120rpx;border-bottom: 1rpx solid #C0C0C0;">
				<view class="u-flex-1"><u-icon name="minus-circle" :size="46" color="#0285ff"></u-icon></view>
				<view class="grid-text u-flex-9 u-font-32">注销</view>
			</view>
			<view class="u-flex" style="height: 120rpx;border-bottom: 1rpx solid #C0C0C0;">
				<view class="u-flex-1"><u-icon name="info-circle" :size="46" color="#0285ff"></u-icon></view>
				<view class="grid-text u-flex-9 u-font-32">注意</view>
			</view>
			<view class="u-flex" style="height: 120rpx;border-bottom: 1rpx solid #C0C0C0;">
				<view class="u-flex-1"><u-icon name="setting" :size="46" color="#0285ff"></u-icon></view>
				<view class="grid-text u-flex-9  u-font-32">设置</view>
			</view>
		</view>
	</view>
	
	
		
	
	
	<u-tabbar v-model="current" :list="list1" active-color="#0285ff"></u-tabbar>
</template>

<script>
    // import store from '@/store/index.js';
	export default {
		data() {
			return {
				current: 0,
				list1: [],
				user:{},
				openid:""
			}
			
		},
		methods: {
			toorder(order){
				uni.navigateTo({
				    url: '/pages/mine/orderlist/orderlist'
				})
			},
			login(){
				uni.navigateTo({
				    url: '/pages/mine/login/login'
				})
			},
			signin(){
				uni.navigateTo({
				    url: '/pages/mine/signin/signin'
				})
			},
			loginOut(){
			  this.$store.commit("loginOut")
			 
			  // uni.navigateTo({
			  //     url: '/pages/mine/login/login'
			  // })
			}
		},
		computed: {
			isLogin(){
			  return this.$store.state.userInfo.isLogin
			}
		  },
		onShow() {
			// uniapp获取缓存中的数据无法赋值给data
			// 因为在uni.getStorage方法内this被重定向了，不再指向外部的data了，
			// 这时候就需要在uni.getStorage方法外部new一个this才可指向data
			let that=this
			uni.getStorage({
				key: 'userInfo',
				success: function (res) {
					that.$store.state.userInfo=res.data
					uni.request({
					  url: "http://127.0.0.1:4523/m1/1653531-0-default/info",
					  success: (res) => {
						let users=res.data.data[0].user
						users.forEach(user=>{
							if(user.username==that.$store.state.userInfo.username){
								that.user=user
							}
						})
					  },
					  fail: (err) => {
						// console.error(err,11111111111);
					  },
					});
				},
				fail: (err) => {
					// console.error(err,11);
				},
			});
			uni.request({
			  url: "http://127.0.0.1:4523/m1/1653531-0-default/info",
			  success: (res) => {
				this.list1=res.data.data[0].list1
				
			  },
			  fail: (err) => {
				// console.error("没有获取到信息");
			  },
			});
			
		},
	}
</script>

<style>
	/* .myend:nth-child(-n+3){
		height: 5000rpx;
		width: 100%;
	} */
	.grid-text{
		height: 50rpx;
		line-height: 50rpx;
	}
	.login{
		width: 1000rpx;
		height: 1000rpx;
		background: url(../../static/VCG41513777962.jpg) no-repeat;
		background-size: 100% 1000rpx;
	}
</style>
